boostinv2 2.2.1
boostinv2.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
31// ----------------------------------------------------------------------------
32
33#ifndef BOOSTINV2_H
34#define BOOSTINV2_H
35
40#ifdef PREINIT_SUPPORTED
41#include "preinit.h"
42#endif
43
44#ifdef MikroCCoreVersion
45 #if MikroCCoreVersion >= 1
46 #include "delays.h"
47 #endif
48#endif
49
50#include "drv_digital_out.h"
51#include "drv_digital_in.h"
52#include "drv_spi_master.h"
53
54
55// -------------------------------------------------------------- PUBLIC MACROS
60
65
66#define BOOSTINV2_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.en = MIKROBUS( mikrobus, MIKROBUS_AN ); \
72 cfg.csn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.psm = MIKROBUS( mikrobus, MIKROBUS_PWM );
74
75
80#define BOOSTINV2_RETVAL uint8_t
81
82#define BOOSTINV2_OK 0x00
83#define BOOSTINV2_INIT_ERROR 0xFF
85
89#define BOOSTINV2_POS_VOUT_5V 0x7FFF
90#define BOOSTINV2_POS_VOUT_6V 0x7B00
91#define BOOSTINV2_POS_VOUT_7V 0x7A20
92#define BOOSTINV2_POS_VOUT_8V 0x7950
93#define BOOSTINV2_POS_VOUT_9V 0x7870
94#define BOOSTINV2_POS_VOUT_10V 0x7790
95#define BOOSTINV2_POS_VOUT_11V 0x76B0
96#define BOOSTINV2_POS_VOUT_12V 0x75E0
97#define BOOSTINV2_POS_VOUT_13V 0x7500
98#define BOOSTINV2_POS_VOUT_14V 0x7420
99#define BOOSTINV2_POS_VOUT_15V 0x7340
101
106#define BOOSTINV2_NEG_VOUT_5V 0x79A2
107#define BOOSTINV2_NEG_VOUT_6V 0x7900
108#define BOOSTINV2_NEG_VOUT_7V 0x786A
109#define BOOSTINV2_NEG_VOUT_8V 0x77D0
110#define BOOSTINV2_NEG_VOUT_9V 0x7744
111#define BOOSTINV2_NEG_VOUT_10V 0x76B0
112#define BOOSTINV2_NEG_VOUT_11V 0x7630
113#define BOOSTINV2_NEG_VOUT_12V 0x75B2
114#define BOOSTINV2_NEG_VOUT_13V 0x7530
115#define BOOSTINV2_NEG_VOUT_14V 0x74B0
116#define BOOSTINV2_NEG_VOUT_15V 0x7474
118 // End group macro
120// --------------------------------------------------------------- PUBLIC TYPES
125
129typedef struct
130{
131 // Output pins
132
133 digital_out_t en;
134 digital_out_t csn;
135 digital_out_t psm;
136 digital_out_t cs;
137
138 // Modules
139
140 spi_master_t spi;
141 pin_name_t chip_select;
142
144
148typedef struct
149{
150 // Communication gpio pins
151
152 pin_name_t miso;
153 pin_name_t mosi;
154 pin_name_t sck;
155 pin_name_t cs;
156
157 // Additional gpio pins
158
159 pin_name_t en;
160 pin_name_t csn;
161 pin_name_t psm;
162
163 // static variable
164
165 uint32_t spi_speed;
166 uint8_t spi_mode;
167 spi_master_chip_select_polarity_t cs_polarity;
168
170 // End types group
172// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
173
178#ifdef __cplusplus
179extern "C"{
180#endif
181
191
200
209
222(
223 boostinv2_t *ctx,
224 uint8_t *wr_buf,
225 uint16_t wr_len,
226 uint8_t *rd_buf,
227 uint16_t rd_len
228);
229
238
247void boostinv2_set_positive_voltage ( boostinv2_t *ctx, uint16_t voltage );
248
257void boostinv2_set_negative_voltage ( boostinv2_t *ctx, uint16_t voltage );
258
267void boostinv2_set_psn ( boostinv2_t *ctx, uint8_t state );
268
269#ifdef __cplusplus
270}
271#endif
272#endif // _BOOSTINV2_H_
273
274 // End public_function group
277
278// ------------------------------------------------------------------------- END
#define BOOSTINV2_RETVAL
Definition boostinv2.h:80
void boostinv2_cfg_setup(boostinv2_cfg_t *cfg)
Config Object Initialization function.
void boostinv2_set_psn(boostinv2_t *ctx, uint8_t state)
Sets PSN depending on input state.
void boostinv2_enable(boostinv2_t *ctx)
Enable analog pin.
void boostinv2_set_negative_voltage(boostinv2_t *ctx, uint16_t voltage)
Sets negative voltage.
BOOSTINV2_RETVAL boostinv2_init(boostinv2_t *ctx, boostinv2_cfg_t *cfg)
Initialization function.
void boostinv2_default_cfg(boostinv2_t *ctx)
Click Default Configuration function.
void boostinv2_generic_transfer(boostinv2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void boostinv2_set_positive_voltage(boostinv2_t *ctx, uint16_t voltage)
Sets postive voltage.
Click configuration structure definition.
Definition boostinv2.h:149
uint8_t spi_mode
Definition boostinv2.h:166
pin_name_t psm
Definition boostinv2.h:161
pin_name_t csn
Definition boostinv2.h:160
spi_master_chip_select_polarity_t cs_polarity
Definition boostinv2.h:167
pin_name_t sck
Definition boostinv2.h:154
pin_name_t mosi
Definition boostinv2.h:153
uint32_t spi_speed
Definition boostinv2.h:165
pin_name_t en
Definition boostinv2.h:159
pin_name_t miso
Definition boostinv2.h:152
pin_name_t cs
Definition boostinv2.h:155
Click ctx object definition.
Definition boostinv2.h:130
digital_out_t cs
Definition boostinv2.h:136
spi_master_t spi
Definition boostinv2.h:140
digital_out_t psm
Definition boostinv2.h:135
digital_out_t csn
Definition boostinv2.h:134
digital_out_t en
Definition boostinv2.h:133
pin_name_t chip_select
Definition boostinv2.h:141